﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace com.ubosi.spider.core.Net
{
    public class ImageSpider
    {
        public static string Download(string fileName, string localPath, string imageUrl)
        {
            try
            {
                System.Net.WebClient wc = new System.Net.WebClient();
                if (File.Exists(localPath + fileName))
                {
                    File.Delete(localPath + fileName);
                }
                if (Directory.Exists(localPath) == false)
                {
                    Directory.CreateDirectory(localPath);
                }
                wc.DownloadFile(imageUrl, localPath + fileName);

                return fileName;
            }
            catch (Exception ex)
            {
                return string.Empty;
            }
        }
    }
}
